/**
 * 系统中，查询结果通用stroe
 */
// 查询结果集合 panelState控制结果弹窗的开关
const state: any = {
  resultList: [],
  panelState: 'init'
};

const mutations = {
  addResult: (state: any, action: any) => {  
    state.resultList = action.value;
  },
  removeResult: (state: any) => {
    state.resultList = null;
  },
  openPanel: (state: any) => {
    state.panelState = 'true';
  },
  closePanel: (state: any) => {
    state.panelState = 'false';
  }
};
const actions = {
  ADD_RESULT: (dispatch: any, value: any) => {
    let action = {
      type: "addResult",
      value,
    };
    dispatch.commit(action);
  },
  REMOVE_RESULT: (dispatch: any) => {
    let action = {
      type: "removeResult"
    };
    dispatch.commit(action);
  },
  OPEN_PANEL: (dispatch: any) => {
    let action = {
      type: "openPanel"
    }
    dispatch.commit(action);
  },
  CLOSE_PANEL: (dispatch: any) => {
    let action = {
      type: "closePanel"
    }
    dispatch.commit(action);
  }
};
const getters = {
  getResultList: (state: any) => {
    return state.resultList;
  },
  getPanelState: (state: any) => {
    return state.panelState;
  }
};


export default {
  namespaced: true,
  state,
  mutations,
  getters,
  actions,
};
